package xyz.lwm.lazycat.netpipe.common.protocol;

/**
 * 消息类型
 *
 * @author lwm
 */
public enum MsgType {

    REGISTER(0, "注册"),
    AUTH(1, "认证"),
    CONNECT(2, "连接"),
    DISCONNECT(3, "断开"),
    KEEPALIVE(4, "心跳"),
    DATA(5, "数据");

    public final int code;

    public final String desc;

    MsgType(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static MsgType valueOf(int code) {
        for (MsgType msgType : MsgType.values()) {
            if (msgType.code == code) {
                return msgType;
            }
        }
        return null;
    }

}
